
package cup.modules.system.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import cup.modules.system.entity.User;
import cup.modules.system.excel.UserExcel;
import liquibase.pro.packaged.U;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * Mapper 接口
 *
 * @author
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

	/**
	 * 自定义分页
	 *
	 * @param page
	 * @param user
	 * @param deptIdList
	 * @param tenantId
	 * @return
	 */
	List<User> selectUserPage(IPage<User> page, @Param("user") User user, @Param("deptIdList") List<Long> deptIdList, @Param("tenantId") String tenantId);

	/**
	 * 获取用户
	 *
	 * @param tenantId
	 * @param account
	 * @param password
	 * @return
	 */
	User getUser(String tenantId, String account, String password);

	/**
	 * 查询拥有审批角色的用户
	 *
	 * @param tenantId
	 * @return
	 */
	List<User> findCityApprovalPeople(@Param("tenantId") String tenantId);

	@Update("UPDATE cup_user SET role_id =#{roleId} WHERE is_deleted = 0 AND id=#{userId}")
	void updateRole(@Param("roleId") String roleIds, @Param("userId") Long userId);

	List<User> findByRoleId(@Param("deptId") String deptId);

	List<User> findByDeptIdPage(IPage<User> page, @Param("user") User user);

	@Select("select name,longitude,latitude,refresh_time refreshTime\n" +
		"from cup_user \n" +
		"where longitude is not null \n" +
		"and latitude is not null")
	List<Map<String, Object>> userGps();

	List<User> findBydDeptIdList(@Param("deptId") String deptId);
}
